/**
 * 防抖函数
 * @param fn 回调函数
 * @param delay 抖动时间
 * @returns
 */
export const debounce = (fn: Function, delay: number = 500) => {
  let timer: number | null = null
  return (...args: any[]) => {
    if (timer) {
      console.log('clear')
      clearTimeout(timer)
    }
    timer = setTimeout(() => {
      console.log('evec timeout')
      fn(...args)
    }, delay)
  }
}
